home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.GoldHead
- {
- var x;
- var y;
- var moveScript;
- var clip;
- var colorR;
- var trans;
- var colorTrans;
- var f2;
- var dir;
- var axis;
- var xDest;
- var yDest;
- var ep;
- var oldDir;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 10;
- var speed = 10;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var pUp = false;
- var life = 10;
- var nc = 0;
- var xA = 0;
- var yA = 0;
- var nudging = false;
- var hc = 0;
- var power = 35;
- var flashing = false;
- var flashC = 0;
- var Name = "goldHead";
- function GoldHead(px, py, pmoveScript)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("goldHead","goldHeadClip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speedVar();
- this.colorR = _root.randRange(-10,10);
- this.trans = new flash.geom.Transform(this.clip);
- this.colorTrans = new flash.geom.ColorTransform(1,1,1,1,this.colorR,this.colorR,this.colorR,0);
- this.trans.colorTransform = this.colorTrans;
- this.parseMoveScript();
- if(_root.flashing)
- {
- this.flashing = true;
- _root.flashing = false;
- }
- _root.stats.created = _root.stats.created + 1;
- }
- function nudge(pxA, pyA, pscale)
- {
- this.nc = 0;
- this.nudging = true;
- var _loc2_ = pscale / 100;
- this.xA = pxA * _loc2_;
- this.yA = pyA * _loc2_;
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.9998,1.0002);
- }
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this[this.axis + "MovT"] = 0;
- this.f2 = "wander";
- this.dir = _root.getDir(this.x,this.y);
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function wander()
- {
- if(random(100) > 96)
- {
- if(random(20) > 18)
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "wait";
- this.c = 0;
- this.ep = _root.randRange(5,15);
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- }
- function wait()
- {
- this.c = this.c + 1;
- if(this.c == this.ep)
- {
- this.f2 = "wander";
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- if(random(100) > 95)
- {
- var _loc2_ = ["L","R","F"];
- this.dir = _loc2_[random(_loc2_.length)];
- }
- }
- function attacking()
- {
- }
- function death()
- {
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 50000;
- var _loc3_ = 0;
- var _loc4_ = random(2) + 1;
- while(_loc3_ < _loc4_)
- {
- _root.createPowerUp([this.x,this.y,"coin25"]);
- _loc3_ = _loc3_ + 1;
- }
- _loc3_ = 0;
- _loc4_ = random(5) + 5;
- while(_loc3_ < _loc4_)
- {
- _root.createPowerUp([this.x,this.y,"coin10"]);
- _loc3_ = _loc3_ + 1;
- }
- _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(75,100),"Yellow"]);
- _loc3_ = 0;
- _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"goldHead","Red"]);
- _loc3_ = _loc3_ + 1;
- }
- _root.createEnemySoul([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"yellow"]);
- _root.createEnemySoul([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"yellow"]);
- _root.createEnemySoul([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"yellow"]);
- _root.audio.playLevel2("goldHeadX",_root.randRange(30,40));
- _root.removeChar("goldHead");
- }
- function death2()
- {
- _root.removeChar("goldHead");
- }
- function main()
- {
- if(this.flashing)
- {
- this.flashC = this.flashC + 1;
- var _loc8_ = 275 - this.flashC * 10;
- this.colorTrans.greenOffset = _loc8_;
- this.colorTrans.redOffset = _loc8_;
- this.colorTrans.blueOffset = _loc8_;
- this.trans.colorTransform = this.colorTrans;
- if(this.flashC == 27)
- {
- this.colorTrans.greenOffset = 0;
- this.colorTrans.redOffset = 0;
- this.colorTrans.blueOffset = 0;
- this.trans.colorTransform = this.colorTrans;
- delete this.flashing;
- delete this.flashC;
- }
- }
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- if(this.oldDir == undefined || this.dir == "F")
- {
- this.clip.body.eyes.gotoAndStop(this.dir);
- }
- else if(this.dir == "U" || this.dir == "D")
- {
- this.clip.body.eyes.gotoAndStop(this.oldDir);
- }
- else if(random(3) > 0)
- {
- if(this.dir == "R")
- {
- this.clip.body.eyes.gotoAndPlay("LtoR");
- }
- else
- {
- this.clip.body.eyes.gotoAndPlay("RtoL");
- }
- }
- else
- {
- this.clip.body.eyes.gotoAndPlay("spin" + this.dir);
- }
- }
- this.oldDir = this.dir;
- if(this.nudging)
- {
- this.xA *= 0.5;
- this.yA *= 0.5;
- this.nc = this.nc + 1;
- _loc8_ = 255 - this.nc * 17;
- this.colorTrans.blueOffset = _loc8_;
- this.colorTrans.greenOffset = _loc8_ / 2;
- this.trans.colorTransform = this.colorTrans;
- if(this.nc == 15)
- {
- this.xA = this.yA = 0;
- this.nudging = false;
- this.colorTrans.blueOffset = this.colorR;
- this.colorTrans.greenOffset = this.colorR;
- this.trans.colorTransform = this.colorTrans;
- }
- }
- var _loc4_ = 0;
- var _loc7_ = _root.broShots.length;
- while(_loc4_ < _loc7_)
- {
- var _loc6_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc6_]))
- {
- var _loc3_ = _root.broShots[_loc4_];
- var _loc5_ = this.life;
- this.life -= _root[_loc3_].power;
- if(this.life < 1)
- {
- this.f2 = "death";
- }
- else
- {
- this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,10);
- _root.audio.playLevel4("goldHeadHit" + (random(2) + 1),_root.randRange(7,15));
- this[this.axis + "MovT"] = 0;
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(_loc5_);
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.f2 = "death";
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 0.2;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 0.2;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 0.2;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 0.2;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- if(random(100) > 98)
- {
- this.clip.body.eyes.clip.gotoAndPlay("blink");
- }
- if(random(10) == 9)
- {
- _root.fxID = _root.fxID + 1;
- _root["goldHeadFX" + _root.fxID] = new classes.fx.GoldHeadFX(this.x,this.y,_root.fxID);
- _root.addFX("goldHeadFX" + _root.fxID);
- }
- this.x += this.xMov + this.xA;
- this.y += this.yMov + this.yA + 0.5 * Math.sin(this.hc += 0.2);
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-